package org.apache.shenyu.plugin.trace;

import org.apache.shenyu.plugin.api.ShenyuPlugin;
import org.apache.shenyu.plugin.base.handler.PluginDataHandler;
import org.apache.shenyu.plugin.request.RequestPlugin;
import org.apache.shenyu.plugin.request.handler.RequestPluginHandler;
import org.apache.shenyu.plugin.trace.handler.TraceIdPluginDataHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * traceId插件自动配置
 */
@Configuration
@ConditionalOnProperty(value = {"shenyu.plugins.trace.enabled"}, havingValue = "true", matchIfMissing = true)
public class TraceIdPluginConfiguration {

    /**
     * TraceId plugin.
     *
     * @return the shenyu plugin
     */
    @Bean
    public ShenyuPlugin traceIdPlugin() {
        return new TraceIdPlugin();
    }

    /**
     * TraceId plugin data handler.
     *
     * @return the plugin data handler
     */
    @Bean
    public PluginDataHandler traceIdPluginDataHandler() {
        return new TraceIdPluginDataHandler();
    }
}
